package com.dishi.hj212.core;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: ds
 * @date: 2024/2/21 14:36
 */

public class DataAreaParser {

    public Map<String, String> readDataAreaMap(String cp) throws Exception {
        Map<String, String> dataAreaMap = new HashMap<>();
        String[] items = cp.split(";");
        for (String item : items) {
            String[] subItem = item.split(",");
            for (String sonItem : subItem) {
                String[] keyValue = sonItem.split("=");
                if (keyValue.length != 2) {
                    throw new Exception();
                }
                dataAreaMap.put(keyValue[0], keyValue[1]);
            }
        }
        return dataAreaMap;
    }
}
